<?php

/*
	$Id: cseo_get_mail_body.inc.php,v 1.1 2010/09/08 10:55:02 akausch Exp $
	
	Copyright 2009 - commerce:SEO
	Author - Daniel Siekiera
	

*/
      // definieren Sie folgende Funktion in Ihrer Applikation
      function html_get_template ($tpl_name, &$tpl_source, &$smarty_obj)
      {
      // Datenbankabfrage um unser Template zu laden,
      // und '$tpl_source' zuzuweisen
      
      $tpl_data = xtc_db_fetch_array(xtc_db_query(" SELECT email_content_html FROM emails WHERE email_name = '".$tpl_name."' AND languages_id = '".$_SESSION['languages_id']."' "));
      
      if (sizeof($tpl_data) == 1) {
      $tpl_source = $tpl_data['email_content_html'];
      return true;
      } else {
      return false;
      }
      }
      
      function html_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
      {
      
      $tpl_data = xtc_db_fetch_array(xtc_db_query(" SELECT email_timestamp FROM emails WHERE email_name = '".$tpl_name."' AND languages_id = '".$_SESSION['languages_id']."' "));
      	
      if (sizeof($tpl_data['email_timestamp']) == 1) {
      $tpl_timestamp = $tpl_data['email_timestamp'];
      return true;
      } else {
      return false;
      }
      }
      
      function html_get_secure($tpl_name, &$smarty_obj)
      {
      
      // angenommen alle Templates sind sicher
      return true;
      }
      
      function html_get_trusted($tpl_name, &$smarty_obj)
      {
      
      // wird fРЎРЉr Templates nicht verwendet
      }
      
      
      // definieren Sie folgende Funktion in Ihrer Applikation
      function txt_get_template ($tpl_name, &$tpl_source, &$smarty_obj)
      {
      // Datenbankabfrage um unser Template zu laden,
      // und '$tpl_source' zuzuweisen
      
      $tpl_data = xtc_db_fetch_array(xtc_db_query(" SELECT email_content_text FROM emails WHERE email_name = '".$tpl_name."' AND languages_id = '".$_SESSION['languages_id']."' "));
      
      if (sizeof($tpl_data) == 1) {
      $tpl_source = $tpl_data['email_content_html'];
      return true;
      } else {
      return false;
      }
      }
      
      function txt_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
      {
      
      $tpl_data = xtc_db_fetch_array(xtc_db_query(" SELECT email_timestamp FROM emails WHERE email_name = '".$tpl_name."' AND languages_id = '".$_SESSION['languages_id']."' "));
      	
      if (sizeof($tpl_data['email_timestamp']) == 1) {
      $tpl_timestamp = $tpl_data['email_timestamp'];
      return true;
      } else {
      return false;
      }
      }
      
      function txt_get_secure($tpl_name, &$smarty_obj) {
		return true;
      }
      
      function txt_get_trusted($tpl_name, &$smarty_obj){}
       
	$smarty->register_resource("html", array("html_get_template",
      "html_get_timestamp",
      "html_get_secure",
      "html_get_trusted"));
     
	$smarty->register_resource("txt", array("txt_get_template",
      "txt_get_timestamp",
      "txt_get_secure",
      "txt_get_trusted")); 

	//Signatur
    $signatursmarty= new Smarty;
	$signatursmarty->caching = false;
	
	$signatursmarty->register_resource("html", array("html_get_template",
      "html_get_timestamp",
      "html_get_secure",
      "html_get_trusted"));
      
	$signatursmarty->register_resource("txt", array("txt_get_template",
      "txt_get_timestamp",
      "txt_get_secure",
      "txt_get_trusted"));
	      
	$adresse = xtc_db_fetch_array(xtc_db_query("SELECT entry_firstname, entry_lastname, entry_street_address, entry_postcode, entry_city FROM address_book WHERE customers_id = 1"));
	
	$signatursmarty->assign('language', $_SESSION['language']);
	$signatursmarty->assign('SHOP_NAME',STORE_NAME);
	$signatursmarty->assign('SHOP_BESITZER',STORE_OWNER);
	$signatursmarty->assign('SHOP_USTID',STORE_OWNER_VAT_ID);
	$signatursmarty->assign('SHOP_ADRESSE_VNAME',$adresse['entry_firstname']);
	$signatursmarty->assign('SHOP_ADRESSE_NNAME',$adresse['entry_lastname']);
	$signatursmarty->assign('SHOP_ADRESSE_STRASSE',$adresse['entry_street_address']);
	$signatursmarty->assign('SHOP_ADRESSE_PLZ',$adresse['entry_postcode']);
	$signatursmarty->assign('SHOP_ADRESSE_ORT',$adresse['entry_city']);
	$signatursmarty->assign('SHOP_EMAIL',STORE_OWNER_EMAIL_ADDRESS);
	$signatursmarty->assign('SHOP_URL',HTTP_SERVER);
	
	$signatur_html = $signatursmarty->fetch('html:signatur');
	$signatur_text = $signatursmarty->fetch('txt:signatur');

?>